package work.timejay.user.controller.books;


import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.tags.Tags;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import work.timejay.common.ApiPageEntity;
import work.timejay.common.ApiResult;
import work.timejay.common.SuperPage;
import work.timejay.user.dto.books.BooksCatalogueInfoDTO;
import work.timejay.user.dto.books.BooksCataloguePageDTO;
import work.timejay.user.vo.books.BooksCataloguePageVO;
import work.timejay.user.entity.books.BooksCatalogue;
import work.timejay.user.service.books.BooksCatalogueService;

import javax.print.attribute.standard.MediaSize;

/**
 * <p>
 * 目录表 前端控制器
 * </p>
 *
 * @author 王文杰
 * @since 2023-12-11
 */
@RestController
@RequestMapping("/books-catalogue")
@Tag(name = "章节接口层",description = "BooksCatalogueController")
public class BooksCatalogueController {

    @Autowired
    private BooksCatalogueService booksCatalogueService;

    /**
     * 分页接口
     */
    @GetMapping()
    public ApiResult<ApiPageEntity<BooksCataloguePageVO>> pageInfo(@Validated BooksCataloguePageDTO<BooksCatalogue> dto) {
        ApiPageEntity<BooksCataloguePageVO> page = booksCatalogueService.pageInfo(dto);
        return ApiResult.success(page);
    }

    /**
     * 章节详情接口
     */
    @GetMapping(value = "/info")
    public ApiResult<BooksCatalogue> getInfo(@Validated BooksCatalogueInfoDTO dto){
        BooksCatalogue bean = booksCatalogueService.getInfo(dto);
        return ApiResult.success(bean);
    }
}

